package icu.makka.yygh.statistics.controller;

import icu.makka.yygh.order.client.OrderFeignClient;
import icu.makka.yygh.result.Result;
import icu.makka.yygh.result.ResultCodeEnum;
import icu.makka.yygh.vo.order.OrderCountQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/admin/statistics")
public class StatisticsController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 获取订单统计数据
     * @param orderCountQueryVo
     * @return
     */
    @GetMapping("/getCountMap")
    public Result getCountMap(OrderCountQueryVo orderCountQueryVo) {
        log.info("获取订单统计数据，orderCountQueryVo={}", orderCountQueryVo);
        Map<String, Object> countMap = orderFeignClient.getCountMap(orderCountQueryVo);
        return null == countMap ? Result.fail(ResultCodeEnum.SERVICE_ERROR) : Result.ok(countMap);
    }
}
